<%--
  Created by IntelliJ IDEA.
  User: 47181
  Date: 2020/5/23
  Time: 21:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="/js/jquery.js"></script>
</head>
<script>
    $(function () {
        chaxuncaixi();

    });

    function chaxuncaixi() {

        $.ajax({
            url: '/backProductCuisineFindAll',
            data: '',
            type: 'get',
            dataType: 'json',
            success: function (data) {
                //将查询出来的菜系全部赋值到菜系的下拉菜单
                console.log(data);
                fuzhicaixi(data[0].object);
            }
        })

    }

    //给菜系赋值
    function fuzhicaixi(data) {
        for (let i = 0; i < data.length; i++) {
            $("#caixi").append("<option value='" + data[i].id + "'>" + data[i].name + "</option>");
        }
    }


    function tijiao() {
        let aa=new FormData();
        aa.append("dishHref",$("#dishHref").val());
        aa.append("dishNav",$("#dishNav").val());
        // let data = {
        //     dishHref: $("#dishHref").val(),
        //     dishNav: $("#dishNav").val(),
        //     dishImgs: $("#dishImgs").val(),
        //     dishTitle: $("#dishTitle").val(),
        //     dishMuch: $("#dishMuch").val(),
        //     dishDescribe: $("#dishDescribe").val()
        // };
        $.ajax({
            url: '/dishAdd',
            type: 'post',
            data: aa,
            dataType: 'text',
            success: function (data) {
                if (data == 1) {
                    $('#homeright').load('/back/dishSelect.jsp')
                } else {
                    alert("操作失败");
                }
            }
        })

    }
</script>
<body>
<form method="post" action="/productAdd" enctype="multipart/form-data">
    <div>
        菜系：<select id="caixi" name="caixi"></select>
    </div>
    <div>
        产品图片：<input type="file" name="dishImgs" id="dishImgs">
    </div>
    <div>
        产品名称：<input type="text" name="dishTitle" id="dishTitle">
    </div>
    <div>
        产品价格：<input type="text" name="dishMuch" id="dishMuch">
    </div>
    <div>
        产品介绍：<input type="text" name="dishDescribe" id="dishDescribe">
    </div>
    <div>
        <input type="submit" value="提交">
    </div>
</form>
</body>
</html>
